﻿@model KnowledgeCommunity.Model.ViewModel.ValueContent

@{
    ViewBag.Title = "Create";
    Layout = "~/Views/Shared/_Layout_zone.cshtml";
}


@section Head{
    <script src="/Scripts/SwfUpload/swfupload.js" type="text/javascript"></script>
    <script src="/Scripts/SwfUpload/plugins/swfupload.queue.js" type="text/javascript"></script>
    <script src="/Scripts/SwfUpload/plugins/swfupload.speed.js" type="text/javascript"></script>
    <script type="text/javascript">
        var swfu;
        window.onload = function () {
            var c1 = document.getElementById("Cont1");
            var c2 = document.getElementById("Cont2");
            var _c1 = c1.value;
            var _c2 = c2.value;
            swfu = new SWFUpload({
                upload_url: "/Accessory/Swfupload?code=" + _c1+"&& type="+_c2,
                flash_url: "/Scripts/SwfUpload/Flash/swfupload.swf",
                file_size_limit: "11500 MB",
                file_types: "*.*",
                file_types_description: "All Files",
                file_upload_limit: 0,
                file_queue_limit: 1,
                debug: false,

                // Button settings
                button_image_url: "/Scripts/SwfUpload/Images/TestImageNoText_65x29.png",
                button_width: "65",
                button_height: "29",
                button_placeholder_id: "spanButtonPlaceHolder",
                button_text: '<span class="theFont">浏览</span>',
                button_text_style: ".theFont { font-size: 16; }",
                button_text_left_padding: 12,
                button_text_top_padding: 3,


                file_dialog_complete_handler: function (numFilesSelected, numFilesQueued) {
                },
                file_queued_handler: function (file) {
                    $("#fileName").val(file.name);
                },
                upload_progress_handler: function (file, complete, total) {
                    var value = complete / total * 100;
                    $("#progressbar").progressbar("value", value);
                    $("#CurrentSpeed").html(SWFUpload.speed.formatBPS(file.currentSpeed));
                },
                upload_success_handler: function (file, data) {
                    alert("文件上传成功");
                    $("#fileProgress").dialog("close");
                }

            });
            $("#btnSubmit").click(function () {
                if (swfu.getStats().files_queued > 0) {
                    $("#fileProgress").dialog({
                        modal: true,
                        width: 400,
                        open: function () {
                            $("#progressbar").progressbar({
                                value: 0
                            });

                            swfu.startUpload();

                        }
                    });
                }

            });

            $("#cancelButton").click(function () {
                swfu.stopUpload();
            });
        };
    </script>
}


<div class="contentcontainer">
    <div class="headings alt">
        <h2>上传附件</h2>
    </div>
    <div class="contentbox">
       <div>
            @Html.HiddenFor(model=>model.Cont1)
            @Html.HiddenFor(model=>model.Cont2)
            <input type="text" id="fileName" />
            <span id="spanButtonPlaceHolder">浏览</span>
            <button id="btnSubmit">
                上传</button>
        </div>
    </div>
</div>

<div title="文件上传进度" id="fileProgress" style="display: none">
    <div id="progressbar">
    </div>
    <button id="cancelButton">
        取消上传</button>
    当前上传速度： <span id="CurrentSpeed"></span>
</div>